from glob import glob
import os
import random

root = 'preprocess_data'
train_ratio = 0.9
dirs = [x[len(root)+1:] for x in glob(os.path.join(root, '*/*'))]
random.shuffle(dirs)

train_dirs = dirs[:int(len(dirs)*train_ratio)]
val_dirs = dirs[int(len(dirs)*train_ratio):]

with open('preprocess_data/train.txt', 'w') as f:
    f.write('\n'.join(train_dirs))

with open('preprocess_data/validation.txt', 'w') as f:
    f.write('\n'.join(val_dirs))
